package com.yqyd.web.controller.hy.web;

import java.util.List;

import com.yqyd.hy.domain.HyGoods;
import com.yqyd.hy.service.IHyGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yqyd.common.annotation.Log;
import com.yqyd.common.core.controller.BaseController;
import com.yqyd.common.core.domain.AjaxResult;
import com.yqyd.common.enums.BusinessType;
import com.yqyd.common.core.page.TableDataInfo;

/**
 * 宏悦—商品Controller
 * 
 * @author Dhq
 * @date 2025-06-18
 */
@RestController
@RequestMapping("/hy/goods")
public class HyGoodsController extends BaseController
{
    @Autowired
    private IHyGoodsService hyGoodsService;

    /**
     * 查询宏悦—商品列表
     */
    @GetMapping("/list")
    public TableDataInfo list(HyGoods hyGoods)
    {
        startPage();
        List<HyGoods> list = hyGoodsService.selectHyGoodsList(hyGoods);
        return getDataTable(list);
    }



    /**
     * 获取宏悦—商品详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(hyGoodsService.selectHyGoodsById(id));
    }

    /**
     * 新增宏悦—商品
     */
    @Log(title = "宏悦—商品", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HyGoods hyGoods)
    {
        return toAjax(hyGoodsService.insertHyGoods(hyGoods));
    }

    /**
     * 修改宏悦—商品
     */
    @Log(title = "宏悦—商品", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HyGoods hyGoods)
    {
        return toAjax(hyGoodsService.updateHyGoods(hyGoods));
    }

    /**
     * 删除宏悦—商品
     */
    @Log(title = "宏悦—商品", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hyGoodsService.deleteHyGoodsByIds(ids));
    }
}
